package main

import (
	"fmt"
	"github.com/bigwhite/workerpool"
	"time"
)

func main() {
	// 开启workpool ,不自动创建 worker , 不堵塞任务
	p := workerpool2.New(5, workerpool2.WithPreAllWorkers(false), workerpool2.WithBlock(false))
	time.Sleep(2 * time.Second)
	for i := 0; i < 10; i++ {
		err := p.Schedule(func() {
			time.Sleep(time.Second * 3)

		})
		if err != nil {
			fmt.Printf("task[%d]: error: %s\n", i, err)
		}
	}
	p.Free()
}
